import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-product/standard-capacity/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 详情-基础信息
export const getDetail = (id) => {
  return request({
    url: '/api/mes-product/standard-capacity/detail',
    method: 'get',
    params: {
      id
    }
  });
};

// 保存或更新产品标准产能
export const capacitySubmit = (row) => {
  return request({
    url: '/api/mes-product/standard-capacity/submit',
    method: 'post',
    data: row
  });
};

// 修改uph
export const changeUph = (params) => {
  return request({
    url: '/api/mes-product/standard-capacity/update/uph',
    method: 'get',
    params: {
      ...params
    }
  });
};

// 检验产品标准产能是否配置所有产线
export const capacityCheck = (row) => {
  return request({
    url: '/api/mes-product/standard-capacity/submit/check',
    method: 'post',
    data: row
  });
};
// 返获取所有产品工段
export const getAllSectionList = () => {
  return request({
    url: '/api/mes-product/work-section/all-section',
    method: 'get'
  });
};

// 查询工段绑定的产线详情
export const getLineListBySection = (id) => {
  return request({
    url: '/api/mes-product/work-section/detail',
    method: 'get',
    params: {
      id
    }
  });
};

// 删除产品标准产能
export const capacityRemove = (ids) => {
  return request({
    url: '/api/mes-product/section/capacity/remove',
    method: 'get',
    params: {
      ids
    }
  });
};

// 详情-站位表分页
export const getTrackList = (current, size, tableId) => {
  return request({
    url: '/api/mes-product/smttable/track/page',
    method: 'get',
    params: {
      tableId,
      current,
      size
    }
  });
};

// 详情-修改日志
export const getLogDetail = (productId) => {
  return request({
    url: '/api/mes-product/standard-capacity/history',
    method: 'get',
    params: {
      productId
    }
  });
};

export const getTrackSheetList = (current, size, params) => {
  return request({
    url: '/api/mes-product/smttable/feeding-track-sheet-page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getTrackDetail = (id) => {
  return request({
    url: '/api/mes-product/smttable/track/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/mes-product/smttable/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const removeTrack = (ids) => {
  return request({
    url: '/api/mes-product/smttable/track/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-product/smttable/submit',
    method: 'post',
    data: row
  });
};

export const addTrack = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-product/smttable/submit',
    method: 'post',
    data: row
  });
};

export const updateTrack = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/submit',
    method: 'post',
    data: row
  });
};

// 替代料详情
export const getTrackReplaceDetail = (id) => {
  return request({
    url: '/api/mes-product/smttable/track/replace/detail',
    method: 'get',
    params: { id }
  });
};

/**
 * 验证机台编码、产品编码
 */
export const verifyMachineCodeOrPartNo = (row) => {
  return request({
    url: '/api/mes-product/smttable/track/check-table-machine-code-part-no',
    method: 'post',
    data: row
  });
};

/**
 * 获取已选中的产品数据
 */
export const getSelectedProduct = (array) => {
  return request({
    url: '/api/mes-admin/partmaster/list-part-master',
    method: 'post',
    data: array
  });
};

export const importData = (formData) => {
  return request({
    url: '/api/mes-product/smttable/importSmt',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
};

export const checkImportData = (data) => {
  return request({
    url: '/api/mes-product/smttable/importSmt/check',
    method: 'post',
    data: data
  });
};

export const updateTable = (data) => {
  return request({
    url: '/api/mes-product/smttable/tableAndTrack/submit',
    method: 'post',
    data: data
  });
};

export const getUphRuleInfo = () => {
  return request({
    url: '/api/mes-product/standard-capacity/uph/rule/info',
    method: 'get'
  });
};

export const uphRuleSet = (data) => {
  return request({
    url: '/api/mes-product/standard-capacity/uph/rule/set',
    method: 'get',
    params: data
  });
};
